package com.ms.game.common.message;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.annotations.MessageType;
import com.xpec.c4.service.common.BaseMessageAction;
import com.xpec.c4.service.group.transportlayer.GroupMessage;
import com.xpec.c4.service.message.MessageAction;

/**
 * 當 server 啟動完成時的通知相關功能
 * 
 * @author TW15010
 */
public class ServerReadyAction extends BaseMessageAction {
	private static final Log log = LogFactory.getLog(ServerReadyAction.class);

	/**
	 * 收到 server 啟動完成通知
	 * 
	 * @param obj
	 *            always null
	 */
	@MessageType(typeCode = MessageTypes.S_ACCOUNT_SERVER_READY_NOTIFY)
	public void recvServerReadyNotify(Object obj) {
		if (log.isInfoEnabled()) {
			log.info("               Server start complete");
		}
	}

	/**
	 * 廣播 server 啟動完成通知給所有的 module
	 */
	public static void broadcastServerReadyNotify() {
		GroupMessage gmsg = new GroupMessage();
		gmsg.setDestModuleID(null);
		gmsg.setMessageType(MessageTypes.S_ACCOUNT_SERVER_READY_NOTIFY);
		MessageAction.sendMessage(gmsg);
	}
}
